package edu.gd.mvndemo;

import edu.gd.utils.DBUtils;

import java.sql.*;

public class Insert {
    public static void insert(String user,String password,String sex,String question,String answer,String introduce){
        Connection connection= DBUtils.getConnection();
        String sql="Insert IGNORE into ttt values(?,?,?,?,?,?)";
        PreparedStatement statement= null;
        try {
            statement = connection.prepareCall(sql);
            statement.setString(1,user);
            statement.setString(2,password);
            statement.setString(3,sex);
            statement.setString(4,question);
            statement.setString(5,answer);
            statement.setString(6,introduce);
            statement.executeUpdate();
            DBUtils.close(statement);
            DBUtils.close(connection);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public static void update(String user,String password){
        Connection connection= DBUtils.getConnection();
        String sql="UPDATE ttt set password=? where user=?";
        PreparedStatement statement= null;
        try {
            statement = connection.prepareCall(sql);
            statement.setString(1,password);
            statement.setString(2,user);
            statement.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
